<template>
    <edit-dialog :centerDialogVisible="visible" :tilte="props.type!=1 ? tilte : '查看' " :default-button="false" @Cancel="handleCancel" :width="width"
        class="edit-dialog">
        <template #content>
                <map-vue  ref="testcomRef" :place="props.place" :type="props.type" class="map"></map-vue>
        </template>

        <template #custom>
            <span class="dialog-footer">
                <el-button class="buttonCancel" @click="handleCancel">{{ props.type!=1?'取消':'返回' }} </el-button>
                <el-button type="primary" class="btn-ok" @click="handleAddSubmit()" :loading="loading" v-if="props.type!=1" >确定</el-button>
            </span>
        </template>
    </edit-dialog>
</template>

<script setup lang="ts">
import editDialog from '@/components/editDialog/index.vue'
import { ref, defineExpose } from 'vue'
import mapVue from '@/views/Example/index.vue'
import { useStore } from 'vuex'


const $store = useStore()
const tilte = ref('请选择地点')
const emit = defineEmits(['cancel', 'confirm'])
const testcomRef = ref()
const coordinate=ref({})
const width = ref('1200px')
const loading = ref(false)
const props = defineProps({
    visible: {
        type: Boolean,
        default: false,
    },
    type:{
        type:Number
    },
    place:{
        type:Object
    }
})

defineExpose({coordinate})


//取消按钮
const handleCancel = () => {
    emit('cancel')
}
//确定按钮
const handleAddSubmit = () => {
    coordinate.value=testcomRef.value.coordinate
    $store.commit('repair/SET_COOR_DINATE', coordinate.value)
    // emit('cancel')
    emit('confirm', coordinate.value)
    emit('cancel')
}

</script>

<style scoped>

:deep(#iframe){
    height: 450px;
}
:deep(.el-dialog__body){
    height: 450px ;
}

</style>